import React from 'react';
import {inject, observer} from 'mobx-react';
import {Button,Spin,Row,Col,Input,Radio,Checkbox} from 'antd';
import { WeaCheckbox, WeaNewScroll,WeaTop,WeaRightMenu, WeaTab, WeaSearchGroup, WeaInput, WeaSelect, WeaDialog, WeaTimePicker, WeaDatePicker, WeaInputNumber } from 'ecCom';
import { Form } from 'antd';
import { WeaSwitch } from 'comsMobx'
import {toJS} from 'mobx';

@inject('planModulStore')
@observer
export default class SwitchFormField extends React.Component {
    render() {
        const {component: Component, attrname, planModulStore, otherParams} = this.props;
        const {addWorkPlanFormOtherParams} = planModulStore;

        let obj = {};

        if(attrname == 'times'){//时间inputNumber加min属性
          obj = {
            value: addWorkPlanFormOtherParams.get(attrname),
            min: 1,
            onChange: (value) => {
              planModulStore.setAddWorkPlanFormOtherParams(attrname, value);
            },
          };
        }else if(attrname == 'remindDateBeforeStart' || attrname == 'remindDateBeforeEnd' ){//inputNumber加min属性
          obj = {
            value: addWorkPlanFormOtherParams.get(attrname),
            min: 0,
            onChange: (value) => {
              planModulStore.setAddWorkPlanFormOtherParams(attrname, value);
            },
          };
        } else if(attrname == 'remindTimeBeforeStart' || attrname == 'remindTimeBeforeEnd'){//inputNumber加min属性
          obj = {
            value: addWorkPlanFormOtherParams.get(attrname),
            min: 0,
            onChange: (value) => {
              planModulStore.setAddWorkPlanFormOtherParams(attrname, value);
            },
          };
        } else {
          obj = {
            value: addWorkPlanFormOtherParams.get(attrname),
            onChange: (value) => {
              planModulStore.setAddWorkPlanFormOtherParams(attrname, value);
            },
          };
        }

        //当component为WwaSelect时
        // if (this.props.options) {
        //     let options = this.props.options;
        //     return (
        //         <Component
        //             {...this.props}
        //             {...obj}
        //             options={options}
        //         >
        //         </Component>
        //     );
        // }

        //当component为WeaInput时,不知道为什么这里直接引入{...this.props}会报错，所以把weainput单独抽离出来了
        if (this.props.style) {
            return (
                <Component ecId={`${this && this.props && this.props.ecId || ''}_Component@2goedv`}
                    //{...this.props}                    
                    {...obj}
                    style={this.props.style}
                    viewAttr={this.props.viewAttr ? this.props.viewAttr: 2}
                >
                </Component>
            );
        }
        
        // //当component为WwaInput时
        // if (this.props.noInput) {
        //     return (
        //         <Component
        //             {...obj}
        //             style={this.props.style}
        //         >
        //         </Component>
        //     );
        // }



        //component为其他类型时
        return (
            <Component ecId={`${this && this.props && this.props.ecId || ''}_Component@j7l6im`}
                {...this.props}
                {...obj}
            >

            </Component>
        );
    }

}